package cn.gcyl.module.biz.dal.mysql.carouselimage;

import cn.gcyl.framework.common.pojo.PageResult;
import cn.gcyl.framework.mybatis.core.mapper.BaseMapperX;
import cn.gcyl.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.gcyl.module.biz.controller.admin.carouselimage.vo.*;
import cn.gcyl.module.biz.dal.dataobject.carouselimage.CarouselImageDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 轮播图 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CarouselImageMapper extends BaseMapperX<CarouselImageDO> {

    default PageResult<CarouselImageDO> selectPage(CarouselImagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CarouselImageDO>()
                .likeIfPresent(CarouselImageDO::getCarouselName, reqVO.getCarouselName())
                .eqIfPresent(CarouselImageDO::getId, reqVO.getId())
                .eqIfPresent(CarouselImageDO::getSort, reqVO.getSort())
                .eqIfPresent(CarouselImageDO::getDisplayLocation, reqVO.getDisplayLocation())
                .eqIfPresent(CarouselImageDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CarouselImageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CarouselImageDO::getId));
    }
    default List<CarouselImageDO> getAppCarouselImageList(CarouselImagePageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CarouselImageDO>()
                .likeIfPresent(CarouselImageDO::getCarouselName, reqVO.getCarouselName())
                .eqIfPresent(CarouselImageDO::getId, reqVO.getId())
                .eqIfPresent(CarouselImageDO::getSort, reqVO.getSort())
                .eqIfPresent(CarouselImageDO::getDisplayLocation, reqVO.getDisplayLocation())
                .eqIfPresent(CarouselImageDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CarouselImageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CarouselImageDO::getId));
    }

}